﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation
{
    public class FriendlyUnit : Unit
    {
        protected Player owner;
        public Player Owner
        {
            get { return owner; }
        }

        public FriendlyUnit(WorldProperties worldProperties, Player owner)
            : base(worldProperties)
        {
            this.owner = owner;

            LoadContent();

            // make sure it loads and draws
            DrawOrder = 50;
            UpdateOrder = 50;
            Visible = true;
            Enabled = true;

            Position = new Vector2(350, 350);
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void LoadContent()
        {
            base.LoadContent();

            Sprite = Game.Content.Load<Texture2D>("Sprites\\Pastel_unit");
        }

        public override void Kill()
        {
            base.Kill();

            // spawn an explosion if we died from loss of life
            if (Life <= 0) new Explosion(worldProperties, this, 1.0f);
            // remove from player unit list
            Owner.Units.Remove(this);
        }

    }
}
